import { Body, Controller, Delete, Get, Param, Post, Put, Query, Res, UploadedFiles, UseInterceptors, } from '@nestjs/common';
import { StudentInfoService } from './student_info.service';
import { FileFieldsInterceptor } from '@nestjs/platform-express';

@Controller('studentInfo')
export class StudentInfoController {
    constructor(
        private readonly studentInfoService: StudentInfoService
    ) { }

    @Post('add')
    @UseInterceptors(FileFieldsInterceptor([
        { name: 'idCardPhoto', maxCount: 1 },
        { name: 'bluePhoto', maxCount: 1 }
    ]))
    add(@UploadedFiles() files: any, @Body() body: any) {
        return this.studentInfoService.add(files, body);
    }

    @Delete('delete')
    delete(@Body() body: any) {
        return this.studentInfoService.delete(body.id);
    }

    @Put('update')
    update(@Body() body: any) {
        return this.studentInfoService.update(body.id, body);
    }

    @Get()
    index() {
        return this.studentInfoService.findAll();
    }
    @Get('getStudentInfoByIdCard')
    getStudentInfoByIdCard(@Query() query: any) {
        return this.studentInfoService.getStudentInfoByIdCard(query);
    }
}
